package com.fudan.backend.util;

import com.fudan.backend.exception.RetCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
    private int status;//约定成功返回200
    private String message;
    private String moreInfo;
    private Object data;

    public R(int status, String message, String moreInfo) {
        this.status = status;
        this.message = message;
        this.moreInfo = moreInfo;
    }

    public R(int status, String message) {
        this.status = status;
        this.message = message;
        this.moreInfo = "";
    }

    public R(int status, String message, Object data) {
        this.status = status;
        this.message = message;
        this.moreInfo = "";
        this.data = data;
    }

    public R(RetCode retCode){
        this.status = retCode.getCode();
        this.message = retCode.getMessage();
        this.moreInfo = "";
        this.data = null;
    }
    public R(RetCode retCode, Object data){
        this.status = retCode.getCode();
        this.message = retCode.getMessage();
        this.moreInfo = "";
        this.data = data;
    }
}
